package sevensoft.创建型模式.单例模式.懒汉式.双重检测锁;

import java.util.Objects;

/**
 * 双重检查锁
 */
public class Singleton3_1 {

    private Singleton3_1(){}

    private static volatile Singleton3_1 singleton31;

    public static  Singleton3_1 getInstance(){
        if ( Objects.nonNull(singleton31) )
            synchronized (Singleton3_1.class) {
                if ( Objects.nonNull(singleton31) )
                    singleton31 = new Singleton3_1();
            }
        return singleton31;
    }
}
